package org.zpp.springboot.rabbitmq.controller;


import java.util.HashMap;
import java.util.Map;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zpp.springboot.rabbitmq.common.Constants;

import com.alibaba.fastjson.JSON;


@Controller
@RequestMapping
public class CommonController {
	
	@Autowired
	private RabbitTemplate rabbitTemplate;
	
	@GetMapping(value="/send")
	@ResponseBody
	public String send(){
		Map<String,String> params = new HashMap<>();
		params.put("name", "zpp");
		params.put("userId", "zpp");
		
		rabbitTemplate.convertAndSend(Constants.EXCHANGE, Constants.ROUTING_KEY, JSON.toJSONString(params));
		return "success";
	}
}